<?php
	class CTRLCmd extends XController 
	{
		public function add()
		{
			$request = XAjax::get();

			// TODO: User auth here.
			// $user = new PrivilegeVerifier();
			// $user->ensurePrivilege();

			CommandModel::add($request['cmd']['station'], $request['cmd']['cmd'], $request['cmd']['arg']);
		}

		public function query()
		{
			$request = XAjax::get();

			// TODO: User auth here.
			// $user = new PrivilegeVerifier();
			// $user->ensurePrivilege();

			$rst = array();
			// $rst = ReplyBuilder::get(0, $request);

			$rst['cmd'] = CommandModel::query($request['station']);

			XAjax::send($rst);
		}

		public function reply()
		{
			$request = XAjax::get();

			// TODO: User auth here.
			// $user = new PrivilegeVerifier();
			// $user->ensurePrivilege();

			CommandModel::reply($request['cmd']['id'], $request['cmd']['reply']);
		}

	}
?>